var BXFileDialog=function(){this.name="BXFileDialog";this.height=476;this.width=750};BXFileDialog.prototype={Open:function(e,i,o){if(!e||!i){alert("Error: Wrong params!");return}if(window.oBXFileDialog&&oBXFileDialog.bOpened)return;this.SetFocus("name");this.oConfig=e;this.UserConfig=i;this.LastSavedConfig={site:this.UserConfig.site,path:this.UserConfig.path,view:this.UserConfig.view,sort:this.UserConfig.sort,sort_order:this.UserConfig.sort_order};this.sessid=e.sessid;this.bSelectFiles=e.select.indexOf("F")!==-1;this.bSelectDirs=e.select.indexOf("D")!==-1;this.RequestUrl=this.GetRequestUrl();this.bOpened=true;var t;var n=window.fd_float_div_cached&&this.CheckReConfig();if(n){t=document.body.appendChild(window.fd_float_div_cached)}else{if(BX("BX_file_dialog"))this.Close();t=document.body.appendChild(document.createElement("DIV"));t.id="BX_file_dialog";t.className="editor_dialog";t.style.position="absolute";t.style.zIndex=e.zIndex||2300;t.style.overflow="hidden";t.innerHTML='<div class="title">'+'<table cellspacing="0" width="100%" border="0">'+"\t<tr>"+'\t\t<td width="100%" class="title-text" onmousedown="jsFloatDiv.StartDrag(arguments[0], BX(\'BX_file_dialog\'));" id="BX_file_dialog_title">Title</td>'+'\t\t<td width="0%"><a id="BX_file_dialog_close" class="close" href="javascript:oBXFileDialog.Close();" onclick="oBXFileDialog.Close(); return false;"></a></td></tr>'+"</table>"+"</div>"+'<div class="content">'+"</div>"}t.style.width=parseInt(this.width)+"px";t.style.height=parseInt(this.height)+"px";this.floatDiv=t;this.content=jsUtils.FindChildObject(this.floatDiv,"div","content");oDialogTitle=BX("BX_editor_dialog_title");var s=function(n){CloseWaitWindow();if(n){if(n.indexOf("BX_FD_LOAD_OK")==-1){alert(mess_ACCESS_DENIED);return}var s=oBXFileDialog.CheckReqLostSessid(n);if(s!==true){if(o){alert(mess_SESS_EXPIRED);return}document.body.removeChild(t);oBXFileDialog.sessid=s;oBXFileDialog.RequestUrl=oBXFileDialog.GetRequestUrl();oBXFileDialog.Open(e,i,true);return}oBXFileDialog.content.innerHTML=n}var l=jsUtils.GetWindowSize(),a=parseInt(l.scrollLeft+l.innerWidth/2-t.offsetWidth/2),d=parseInt(l.scrollTop+l.innerHeight/2-t.offsetHeight/2);jsFloatDiv.Show(t,a,d);BX.addCustomEvent(window,"onFileDialogLoaded",function(){if(window.oBXDialogTree)oBXDialogTree.SetPath(e.path||i.path||"")});BX.onCustomEvent(window,"onAfterFileDialogShow")};ShowWaitWindow();this.SetEventHandlers();if(n){this.reConfigDialog();s();return}BX.ajax.get(this.RequestUrl+"&action=start&path="+this.oConfig.path+"&add_to_menu="+(this.oConfig.showAddToMenuTab?"1":""),s)},CheckReConfig:function(){return!(BX.browser.IsIE()||this.oConfig.operation!=window.fd_config_cached.operation||this.oConfig.allowAllFiles!=window.fd_config_cached.allowAllFiles||this.oConfig.select!=window.fd_config_cached.select||this.oConfig.lang!=window.fd_config_cached.lang||this.oConfig.showAddToMenuTab!=window.fd_config_cached.showAddToMenuTab||this.oConfig.showUploadTab!=window.fd_config_cached.showUploadTab||this.oConfig.site!=window.fd_config_cached.site)},reConfigDialog:function(){if(this.oConfig.fileFilter!=window.fd_config_cached.fileFilter)oBXDialogControls.Filter=new __FileFilter;var e=this.oConfig.path||this.UserConfig.path||"";oBXFileDialog.SubmitFileDialog=SubmitFileDialog;if(this.oConfig.operation=="S"&&this.oConfig.showAddToMenuTab&&!window.oBXMenuHandling)window.oBXMenuHandling=new BXMenuHandling;oBXDialogTree.SetPath(e)},Close:function(){this.SaveConfig();if(window.oBXFDContextMenu)oBXFDContextMenu.menu.PopupHide();var e=BX("BX_file_dialog");jsFloatDiv.Close(e);oBXFileDialog.bOpened=false;jsFloatDiv.Close(this.floatDiv);e.parentNode.removeChild(e);window.fd_float_div_cached=this.floatDiv;window.fd_config_cached=this.oConfig;this.UnsetEventHandlers();if(window.fd_site_list&&window.fd_site_list.PopupHide)window.fd_site_list.PopupHide();if(oBXDialogTree.curSelectedItem){oBXDialogTree.UnHighlightElement(oBXDialogTree.curSelectedItem.oTitle)}oBXDialogTree.curSelectedItem=null},GetRequestUrl:function(e,i){return"/bitrix/admin/file_dialog.php?"+"lang="+this.oConfig.lang+"&operation="+this.oConfig.operation+"&site="+(e||this.oConfig.site)+"&sessid="+(i||this.sessid)+"&get_files="+(this.bSelectFiles?1:"")},CheckReqLostSessid:function(e){var i="BX_FD_DUBLICATE_ACTION_REQUEST",o=e.indexOf(i);if(o==-1)return true;var t=o+i.length;return e.substr(t,e.indexOf("--\x3e")-t)},SaveConfig:function(e){if(!e)e=oBXFileDialog.UserConfig;else oBXFileDialog.UserConfig=e;if(!this.oConfig.saveConfig||!e||!window.BXFDCompareObj||BXFDCompareObj(this.LastSavedConfig,e))return;var i=new JCHttpRequest;i.Action=function(i){oBXFileDialog.LastSavedConfig=BXFDCopyObj(e)};i.Send(oBXFileDialog.GetRequestUrl(getSite())+"&action=set_config&path="+jsUtils.urlencode(e.path)+"&view="+e.view+"&sort="+e.sort+"&sort_order="+e.sort_order)},SetFocus:function(e){this.dialogFocus=e},SetEventHandlers:function(){window.BXFD_OnKeyDown=function(e){return oBXFileDialog.OnKeyDown(e)};jsUtils.addEvent(document,"keydown",window.BXFD_OnKeyDown)},UnsetEventHandlers:function(){jsUtils.removeEvent(document,"keydown",window.BXFD_OnKeyDown)},OnKeyDown:function(e){if(!e)e=window.event;if(!e||e.shiftKey||e.ctrlKey||e.altKey)return;if(this.dialogFocus=="tree"){oBXDialogTree.OnKeyDown(e)}else if(this.dialogFocus=="window"){oBXDialogWindow.OnKeyDown(e)}else{if(e.keyCode==27)this.Close();if(e.keyCode==13){if(e.target)e.targetElement=e.target;else if(e.srcElement)e.targetElement=e.srcElement;if(window.oBXDialogControls&&e.targetElement==oBXDialogControls.dirPath.oInput)oBXDialogTree.SetPath(oBXDialogControls.dirPath.Get())}}}};
//# sourceMappingURL=file_dialog.map.js